﻿using ScaffoldSystem.Repositories;
using ScaffoldSystem.Repositories.Abstract;
using ScaffoldSystem.Repositories.Concrete;
using ScaffoldSystem.Services.Abstract;
using ScaffoldSystem.Services.Concrete;
using System.Web.Mvc;
using Unity;
using Unity.AspNet.Mvc;

namespace ScaffoldWeb.Infrastructure
{
    // https://www.cnblogs.com/artech/archive/2011/12/13/asp-mvc-unity.html
    // https://blog.csdn.net/wxm2106/article/details/101267009
    // https://debugmode.net/2014/08/28/resolving-dependencies-in-asp-net-mvc-5-using-unity-container/
    public class UnityConfigure
    {
        public static void RegisterContainer()
        {
            UnityContainer container = new UnityContainer();

            container.RegisterType<ISysUserService, SysUserService>();
            container.RegisterType<ISysDeptService, SysDeptService>();
            container.RegisterType<ISysUserRepository, SysUserRepository>();
            container.RegisterType<ISysDeptRepository, SysDeptRepository>();
            container.RegisterType<EFDbContext, EFDbContext>();

            DependencyResolver.SetResolver(new UnityDependencyResolver(container));
        }
    }

}